<?php
//资源插件----
//使用方法 pluginPaths  法1
// $application = new Zend_Application(APPLICATION_ENV, array(
// 		'pluginPaths' => array(
// 				'Cff_Application_Resource_View' => 'Cff/Application/Resource',
// 		),
// 		'resources' => array(
// 				'FrontController' => array(
// 						'controllerDirectory' => APPLICATION_PATH . '/controllers',
// 				),
// 		),
// ));

//或者：法2 : pluginPaths.Cff_Application_Resource_View='Cff/Application/Resource'
class Cff_Application_Resource_View extends Zend_Application_Resource_ResourceAbstract {
	protected $_view;
	public function init() {
		// Return view so bootstrap will store it in the registry
		return $this->getView ();
	}
	public function getView() {
		if (null === $this->_view) {
			$options = $this->getOptions ();
			$title = '';
			if (array_key_exists ( 'title', $options )) {
				$title = $options ['title'];
				unset ( $options ['title'] );
			}
			
			$view = new Zend_View ( $options );
			$view->doctype ( 'XHTML1_STRICT' );
			$view->headTitle ( $title );
			$view->headLink ()->appendStylesheet ( '/css/site.css' );
			$view->headScript ()->appendfile ( '/js/analytics.js' );
			
			$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper ( 'ViewRenderer' );
			$viewRenderer->setView ( $view );
			
			$this->_view = $view;
		}
		return $this->_view;
	}
}
